Remove unnecessary `Vec` allocation when iterating.
authorCorey Farwell <coreyf@rwell.org>
Tue, 3 May 2016 01:17:01 +0000 (21:17 -0400)
committerCorey Farwell <coreyf@rwell.org>
Tue, 3 May 2016 01:17:01 +0000 (21:17 -0400)
src/cargo/util/toml.rs

index 5cd4ad43b7ffd4a3d70c86cc00fa67f3b2dd4146..288aa2be59a539d84ced55b688990f932fb058fa 100644 (file)
@@ -626,9 +626,8 @@ impl TomlManifest {
 /// Will check a list of toml targets, and make sure the target names are unique within a vector.
 /// If not, the name of the offending binary target is returned.
 fn unique_names_in_targets(targets: &[TomlTarget]) -> Result<(), String> {
-    let values = targets.iter().map(|e| e.name()).collect::<Vec<String>>();
     let mut seen = HashSet::new();
-    for v in values {
+    for v in targets.iter().map(|e| e.name()) {
         if !seen.insert(v.clone()) {
             return Err(v);
         }